/*
 *  flow.c
 *  Timers
 *
 *  Created by Phillip LeBlanc on 11/19/08.
 *  Copyright 2008 TeamFEV. All rights reserved.
 *
 */

#include "common.h"

int select_gametype()
{
	setBG(addpath("images/gametype.jpg"));
	
	return event_loop_gametype();

} 

int event_loop_gametype()
{
	int status;
	SDL_Event event;
    while(SDL_WaitEvent(&event)) {
        switch(event.type) {
            case SDL_KEYDOWN:
				if (event.key.keysym.sym == SDLK_ESCAPE)
					return -1;
					

            case SDL_MOUSEBUTTONDOWN:
                // Handle mouse clicks here.
				status = checkCoords(event.button.x, event.button.y, GTYPE);
				if (status!=-1)
					return status;
                break;

            case SDL_QUIT:
                SDL_Quit();
				Mix_CloseAudio();
				TTF_CloseFont(font);
				exit(0);
                
            default:
                break;
        }   // End switch
            
    }   // End while
	
	return -1;

}

int event_loop_start()
{
	setBG(addpath("images/start.jpg"));
	SDL_Event event;
    while(SDL_WaitEvent(&event)) {
        switch(event.type) {
            case SDL_KEYDOWN:
				if (event.key.keysym.sym == SDLK_ESCAPE)
					return -1;
				else
					return 1;
					

            case SDL_MOUSEBUTTONDOWN:
                // Handle mouse clicks here.
				return 1;

            case SDL_QUIT:
                SDL_Quit();
				Mix_CloseAudio();
				TTF_CloseFont(font);
				exit(0);
                
            default:
                break;
        }   // End switch
            
    }   // End while
	
	return -1;

}

void event_loop_undef(void)
{
	setBG(addpath("images/overlay.jpg"));
	displayNotification("That gametype is not defined!", 1);
	SDL_Flip(screen);
	SDL_Event event;
	while(SDL_WaitEvent(&event)) {
        switch(event.type) {
            case SDL_KEYDOWN:
            case SDL_MOUSEBUTTONDOWN:
				return;

            case SDL_QUIT:
                SDL_Quit();
				Mix_CloseAudio();
				TTF_CloseFont(font);
				exit(0);
                
            default:
                break;
        }   // End switch
            
    }   // End while
}
